package com.twu.biblioteca.control;

import com.twu.biblioteca.library.main.Library;
import com.twu.biblioteca.user.User;
import com.twu.biblioteca.user.UserAccounts;
import java.util.Scanner;

public class Login {

    Scanner inputScanner;

    public Login(Scanner scanner) {
        inputScanner = scanner;
    }

    public Library loginMenu(){
        String libraryNumber, password;
        System.out.print(Strings.enterLibNum);
        libraryNumber = inputScanner.nextLine();
        System.out.print(Strings.enterPassword);
        password = inputScanner.nextLine();
        User user = new UserAccounts().validateUser(libraryNumber, password);
        if( user != null){
            System.out.println(Strings.validationSuccess);
            return new Library(user, inputScanner);
        }
        else{
            System.out.println(Strings.validationFailure);
            return null;
        }
    }
}
